<?php

namespace app\home\model\store;

use basic\BaseModel;
use traits\ModelTrait;

/**
 * Class StoreDevice
 * @package app\home\model\store
 */
class StoreDevice extends BaseModel
{
    use ModelTrait;

    /**
     * 主键ID
     * @var string
     */
    protected $pk = "id";

    /**
     * 模型名称
     * @var string
     */
    protected $name = "store_device";

    /**
     * 获取分页
     * @param array $where
     * @return array
     */
    public static function systemPage(array $where)
    {
        $model = new self;
        if ($where['status'] != '') $model = $model->where('d.status', $where['status']);
        if ($where['device_name'] != '') $model = $model->where('d.device_name', 'LIKE', "%$where[device_name]%");
        if ($where['store_id'] != '') $model = $model->where('d.store_id', $where["store_id"]);
        $model = $model->alias("d")
            ->join("system_store s", "s.id= d.store_id", "LEFT")
            ->where("s.is_del", 0)
            ->where("d.is_del", 0);
        $model = $model->where("d.wxapp_id", self::$wxapp_id);
        $model = $model->field("d.*")->order("d.id DESC");
        return self::page($model, $where);
    }

}